using ChikovMF.Application.Features.Tags.DeleteTag;
using Microsoft.EntityFrameworkCore;

namespace ChikovMF.Tests.Tags.Commands;

public class DeleteTagTest : TestCommandBase
{
    [Fact]
    public async Task DeleteTagTest_Success()
    {
        var handler = new DeleteTagCommandHandler(_context);
        var command = new DeleteTagCommand
        {
            TagId = new Guid("a3446f5d-5e34-4ae9-aef9-fe0b584bb9cd")
        };
        var oldTag = await _context.Tags.FirstOrDefaultAsync(tag => tag.TagId == command.TagId);

        await handler.Handle(
            command,
            CancellationToken.None
        );

        Assert.NotNull(oldTag);
        Assert.Null(await _context.Tags.FirstOrDefaultAsync(tag => tag.TagId == command.TagId));
    }
}